<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Page Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>

    <div id="box">
        <div v-bind:class="{ active: isActive }">
        </div>
        <hr>
        <div class="static" v-bind:class="{ active: isActive, 'text-danger': hasError }">
        </div>
        <hr>
        <div v-bind:class="classObject"></div>
        <div v-bind:class="[activeClass, errorClass]"></div>
        <div v-bind:class="[isActive ? activeClass : '', errorClass]"></div>
        <div v-bind:class="[{ active: isActive }, errorClass]"></div>
    </div>
</body>
<script>
    var vm = new Vue({
        el: "#box",
        data: {
            isActive: true,
            error: null,
            hasError: false,
            activeClass: 'active',
            errorClass: 'text-danger',
            classObject: {
                active: true,
                'text-danger': false
            },

        },
        // 我们也可以在这里绑定一个返回对象的计算属性。这是一个常用且强大的模式：
        computed: {
            classObject: function() {
                return {
                    active: this.isActive && !this.error,
                    'text-danger': this.error && this.error.type === 'fatal'
                }
            }
        }
    })
</script>

</html>